package cool.tianyou.blue.bird.config;

import cool.tianyou.blue.bird.common.advice.AuthInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * LocalWebMvcConfigurer
 *
 * @author likeguo
 */
@Configuration
@RequiredArgsConstructor
public class LocalWebMvcConfigurer implements WebMvcConfigurer {

    private final AuthInterceptor authInterceptor;

    private final AuthConfiguration authConfiguration;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 登录认证拦截
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(authConfiguration.getAuthExclusionPaths());
    }
}
